refactor: Take default versions from yaml declarations#121
refactor: Take default versions from yaml declarations#121andrzej-janczak merged 8 commits intomainfrom
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
|
I think we should discuss this and align with the needs for #119. If we are going to fetch configurations without token from the API, maybe we can also get the tools versions from the public API instead of having them on the yamls |
|
Ok, so yaml could be always just a fallback just in case ... :) |
Alright, that is fair 👌 |
| } | ||
|
|
||
| // GetRuntimeVersions returns a map of runtime names to their default versions | ||
| func GetRuntimeVersions() map[string]string { |
There was a problem hiding this comment.
Seems strange that we added 'DefaultVersion string yaml:"default_version"' to the pluginConfig and it is not about 'loading the full plugin configuration' or something. And there is this method exclusively about the runtimes.
I guess it does not hurt, but would expect, that if we are making this changes, the init to be the spot that you would load the plugins configurations and use them. Why have an hardcoded list on the init, and then load them just for the default_version? Might as well, load them, and use them.
Checking if some tools like 'enigma' we can add an optional 'enableByDefault' or something that would be off for the ones we don't want to add automatically
There was a problem hiding this comment.
First two points are addressed
3rd one looks like candidate for another PR, we can discuss it 👍
e92b2a2 to
fec7a17
Compare
func enrichToolsWithVersion(tools []Tool) ([]Tool, error) {
client := &http.Client{
Timeout: 10 * time.Second,
}
// Create a new GET request
req, err := http.NewRequest("GET", "https://api.codacy.com/api/v3/tools", nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
// Send the request
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("failed to get tools from Codacy API: status code %d", resp.StatusCode)
}
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
var response ToolsResponse
if err := json.Unmarshal(body, &response); err != nil {
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
}
// Create a map of tool UUIDs to versions
versionMap := make(map[string]string)
for _, tool := range response.Data {
versionMap[tool.Uuid] = tool.Version
}
// Enrich the input tools with versions
for i, tool := range tools {
if version, exists := versionMap[tool.Uuid]; exists {
tools[i].Version = version
}
}
return tools, nil
}I think we already fetch versions from API. |
|
Sorry It got so big, I did not expect that 😓 There are some good parts like removing some common code 😉 |
586bb1c to
2c8dfe9
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Major changes: - Introduce new plugin management system with PluginManager - Refactor runtime and tool configuration handling - Centralize version management for tools and runtimes - Remove hardcoded tool configurations in favor of plugin-based approach - Improve error handling and logging - Add support for dynamic runtime dependencies - Sort tools and runtimes in configuration output The changes make the codebase more maintainable and extensible by: - Reducing code duplication - Improving separation of concerns - Making tool and runtime management more dynamic - Centralizing configuration management
- Upgraded eslint version from 8.57.0 to 9.3.0 in the test configuration. - Cleaned up imports in getTools.go by removing unused packages. These modifications enhance the configuration's clarity and ensure compatibility with the latest tool versions.
- Added environment information output including OS and PowerShell version. - Improved directory comparison logging to show normalized paths and contents. - Enhanced error handling with detailed messages during test execution. - Updated test execution logging for better clarity on test progress. These changes improve the visibility and traceability of the integration tests, making it easier to diagnose issues and understand the test flow.
c34ab1b to
115abbc
Compare
5b57626 to
3231cba
Compare
|
Codacy detected 25 issues in this pull request (1 are potential false positives) |
| import ( | ||
| "bytes" | ||
| "strings" | ||
| "text/template" |
There was a problem hiding this comment.
🚫 Codacy found a high Security issue: When working with web applications that involve rendering user-generated content, it's important to properly escape any HTML content to prevent Cross-Site Scripting (XSS) attacks.
The issue identified by the Semgrep linter is related to the potential for Cross-Site Scripting (XSS) attacks when rendering user-generated content with the text/template package in Go. If user input is not properly escaped, it could lead to the injection of malicious scripts that execute in the user's browser.
To mitigate this risk, you should use the html/template package instead of the text/template package. The html/template package automatically escapes HTML content, providing an additional layer of security against XSS attacks.
Here is the code suggestion to fix the issue:
| "text/template" | |
| "html/template" |
This comment was generated by an experimental AI tool.
| if config.Name == "python" { | ||
| installDir = path.Join(runtimesDir, "python") | ||
| } else { | ||
| installDir = path.Join(runtimesDir, fileName) |
There was a problem hiding this comment.
🚫 Codacy found a high ErrorProne issue: path.Join(...) always joins using a forward slash.
The issue identified by the Semgrep linter is that the path.Join(...) function in Go always uses forward slashes (/) as path separators, regardless of the operating system. This can lead to problems on Windows systems, where the standard path separator is a backslash (\). Therefore, using path.Join with a filename that may contain backslashes can result in incorrect paths.
To fix this issue, we can use filepath.Join instead of path.Join, as filepath.Join will use the correct path separator for the current operating system.
Here's the code suggestion to fix the issue:
| installDir = path.Join(runtimesDir, fileName) | |
| installDir = filepath.Join(runtimesDir, fileName) |
This comment was generated by an experimental AI tool.
|
|
||
| // If the binary path is relative, join it with the install directory | ||
| if !path.IsAbs(binaryPath) { | ||
| binaryPath = path.Join(installDir, binaryPath) |
There was a problem hiding this comment.
🚫 Codacy found a high ErrorProne issue: path.Join(...) always joins using a forward slash.
The issue identified by the Semgrep linter is that path.Join(...) uses forward slashes (/) as the path separator, which can lead to incorrect paths on Windows systems where the expected separator is a backslash (\). This can cause problems when the resulting path is used to access files on the filesystem.
To fix this issue, you can use filepath.Join(...) instead of path.Join(...). The filepath package automatically uses the correct path separator for the operating system on which the code is running.
Here’s the suggested code change:
| binaryPath = path.Join(installDir, binaryPath) | |
| binaryPath = filepath.Join(installDir, binaryPath) |
This comment was generated by an experimental AI tool.
| // For Python, we want to use a simpler directory structure | ||
| var installDir string | ||
| if config.Name == "python" { | ||
| installDir = path.Join(runtimesDir, "python") |
There was a problem hiding this comment.
🚫 Codacy found a high ErrorProne issue: path.Join(...) always joins using a forward slash.
The issue identified by the Semgrep linter indicates that path.Join(...) is being used to concatenate paths, but it is being done with a hardcoded string "python" that may not be compatible with the operating system's path separator. In Go, path.Join is intended for use with paths that should be treated as POSIX-style paths (using forward slashes), while filepath.Join should be used for file paths that are OS-aware and will use the correct separator for the current operating system.
To fix the issue, you should replace path.Join with filepath.Join, which will ensure that the correct path separator is used based on the operating system.
Here's the suggested code change:
| installDir = path.Join(runtimesDir, "python") | |
| installDir = filepath.Join(runtimesDir, "python") |
This comment was generated by an experimental AI tool.
| } | ||
|
|
||
| // GetDownloadURL generates the download URL based on the template | ||
| func GetDownloadURL(urlTemplate string, fileName string, version string, mappedArch string, mappedOS string, extension string, releaseVersion string) string { |
There was a problem hiding this comment.
The issue identified by the Lizard linter is related to the number of parameters in the GetDownloadURL function. Having too many parameters can make the function harder to use and understand, as well as increase the cognitive load for anyone maintaining the code. The limit set by the linter suggests that functions should ideally have no more than 5 parameters.
To address this issue, we can encapsulate the parameters into a single struct, which will reduce the number of parameters in the function signature. Here's a code suggestion that implements this change:
| func GetDownloadURL(urlTemplate string, fileName string, version string, mappedArch string, mappedOS string, extension string, releaseVersion string) string { | |
| func GetDownloadURL(urlTemplate string, data templateData) string { |
In this suggestion, we assume that templateData is a struct that contains all the necessary fields (like FileName, Version, MappedArch, etc.) that were previously passed as separate parameters. You would also need to create an instance of templateData before calling GetDownloadURL.
This comment was generated by an experimental AI tool.
| $relativePath = $_.FullName.Replace($expectedDir, '').TrimStart('\') | ||
| $actualSubDir = Join-Path $actualDir $relativePath | ||
| Write-Host "`nChecking subdirectory: $relativePath" | ||
| Write-Host "Expected dir: $($_.FullName)" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used to output information. While Write-Host works for displaying messages to the console, it is not recommended because it doesn't allow for capturing or redirecting output, and may not function correctly in all environments or hosts. Instead, it's better to use other cmdlets like Write-Output, Write-Verbose, or Write-Information, which provide more flexibility and are more suitable for scripting.
To address this issue, you can replace the Write-Host command with Write-Output for the specific line flagged by the linter.
Here's the suggested code change:
| Write-Host "Expected dir: $($_.FullName)" | |
| Write-Output "Expected dir: $($_.FullName)" |
This comment was generated by an experimental AI tool.
| function Normalize-Config { | ||
| param ([string]$file) | ||
|
|
||
| Write-Host "Normalizing config file: $file" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is used to output messages. While Write-Host can display messages to the console, it has limitations: it does not allow for capturing or redirecting output, and it may not function correctly in all environments or hosts. Instead, it's recommended to use Write-Output, Write-Verbose, or Write-Information for better flexibility and compatibility.
To address this issue, you can replace Write-Host with Write-Information, which is more suitable for logging informational messages that can be captured or redirected.
Here's the suggested code change:
| Write-Host "Normalizing config file: $file" | |
| Write-Information "Normalizing config file: $file" |
This comment was generated by an experimental AI tool.
| Write-Host " $($_.FullName.Replace($expectedDir, ''))" | ||
| } | ||
|
|
||
| Write-Host "`nActual directory contents:" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is not recommended for use because it directly writes to the console and cannot be captured or redirected. This can lead to problems in scripts where output needs to be processed or logged. Instead, it is better to use Write-Output, Write-Verbose, or Write-Information which provide more flexibility in handling output.
To fix the issue, you can replace the Write-Host command with Write-Output. Here’s the suggested change:
| Write-Host "`nActual directory contents:" | |
| Write-Output "`nActual directory contents:" |
This comment was generated by an experimental AI tool.
|
|
||
| if (-not (Test-Path $actualSubDir)) { | ||
| Write-Host "❌ Directory $label/$($_.Name) does not exist in actual output" | ||
| Write-Host "❌ Directory $label/$relativePath does not exist in actual output" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is being used to output messages. While Write-Host directly writes to the console, it has limitations: it does not allow for output to be captured, redirected, or suppressed, which can lead to issues in automated scripts or environments without a host. The recommended practice is to use Write-Output, Write-Verbose, or Write-Information instead, which provide more flexibility in handling output.
To fix the issue, we can replace Write-Host with Write-Output in the specified line.
Here’s the code suggestion:
| Write-Host "❌ Directory $label/$relativePath does not exist in actual output" | |
| Write-Output "❌ Directory $label/$relativePath does not exist in actual output" |
This comment was generated by an experimental AI tool.
| Write-Host "Actual should be: $actualFile" | ||
| Write-Host "Current directory structure:" | ||
| Get-ChildItem -Path $actualDir -Recurse | ForEach-Object { | ||
| Write-Host " $($_.FullName)" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is generally discouraged because it outputs directly to the console and cannot be captured or redirected. This can lead to problems in environments where the output needs to be processed or logged. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information, which provide better flexibility and usability in scripts.
To address this issue, you can replace Write-Host with Write-Output. Here's the code suggestion:
| Write-Host " $($_.FullName)" | |
| Write-Output " $($_.FullName)" |
This comment was generated by an experimental AI tool.
| $actualSubDir = Join-Path $actualDir $relativePath | ||
| Write-Host "`nChecking subdirectory: $relativePath" | ||
| Write-Host "Expected dir: $($_.FullName)" | ||
| Write-Host "Actual dir: $actualSubDir" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that the Write-Host cmdlet is being used to output information to the console. While Write-Host does display messages, it has limitations: it does not work in all PowerShell hosts, cannot be captured or redirected, and is not suitable for logging or outputting information that may need to be processed further. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information for better compatibility and flexibility.
To resolve this issue, you can replace Write-Host with Write-Output for the specific line mentioned. Here’s the code suggestion:
| Write-Host "Actual dir: $actualSubDir" | |
| Write-Output "Actual dir: $actualSubDir" |
This comment was generated by an experimental AI tool.
| # List directory contents before comparison | ||
| Write-Host "`nExpected directory contents:" | ||
| Get-ChildItem -Path $expectedDir -Recurse | ForEach-Object { | ||
| Write-Host " $($_.FullName.Replace($expectedDir, ''))" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used to output information to the console. While Write-Host can display text to the user, it has several limitations: it does not allow for redirection, capturing, or suppression of output, which can lead to issues in scripts that need to log information or run in different environments. Instead, it's recommended to use other cmdlets like Write-Output, Write-Verbose, or Write-Information for better flexibility and compatibility.
To resolve this issue, you can replace Write-Host with Write-Output, which allows the output to be captured or redirected if needed.
Here is the suggested code change:
| Write-Host " $($_.FullName.Replace($expectedDir, ''))" | |
| Write-Output " $($_.FullName.Replace($expectedDir, ''))" |
This comment was generated by an experimental AI tool.
| Write-Host "Comparing directories:" | ||
| Write-Host "Expected dir: $expectedDir" | ||
| Write-Host "Actual dir: $actualDir" | ||
| Write-Host "Label: $label" |
There was a problem hiding this comment.
The issue identified by PSScriptAnalyzer is that Write-Host is not recommended because it directly writes to the console and does not allow for output redirection, capturing, or suppression. This can lead to problems in scripts that are intended to be more flexible or reusable in different contexts, such as when they are run in environments without a console or when the output needs to be processed further.
To address this, you can replace Write-Host with Write-Output, which is more versatile and allows the output to be captured or redirected.
Here's the suggested code change:
| Write-Host "Label: $label" | |
| Write-Output "Label: $label" |
This comment was generated by an experimental AI tool.
| $SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| $CLI_PATH = Join-Path (Get-Location) "cli-v2.exe" | ||
|
|
||
| Write-Host "=== Environment Information ===" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used to output information to the console. While Write-Host does display text directly to the host, it has limitations such as not being able to be captured or redirected, which can lead to issues in scripts that may be run in different environments or contexts. The linter suggests using Write-Output, Write-Verbose, or Write-Information instead, as these cmdlets provide more flexibility and are better suited for scripting.
To resolve this issue, you can replace Write-Host with Write-Output, which allows the output to be captured or redirected if necessary.
Here is the suggested single line change:
| Write-Host "=== Environment Information ===" | |
| Write-Output "=== Environment Information ===" |
This comment was generated by an experimental AI tool.
| exit 1 | ||
| } | ||
| Write-Host "✅ $label/$($_.Name) matches expected" | ||
| Write-Host "✅ $label/$relativePath matches expected" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is not recommended for outputting messages in PowerShell scripts because it writes directly to the console and cannot be redirected or captured. This can lead to problems in environments where the script's output needs to be processed further or logged. Instead, it is advisable to use Write-Output, Write-Verbose, or Write-Information, which provide more flexibility and are better suited for scripting.
To resolve this issue, you can replace Write-Host with Write-Information, which is a more appropriate choice for logging informational messages.
Here's the code suggestion to fix the issue:
| Write-Host "✅ $label/$relativePath matches expected" | |
| Write-Information "✅ $label/$relativePath matches expected" |
This comment was generated by an experimental AI tool.
| $diff = Compare-Object $expectedContent $actualContent -PassThru | ||
| if ($diff) { | ||
| Write-Host "❌ $label/$($_.Name) does not match expected" | ||
| Write-Host "❌ $label/$relativePath does not match expected" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is being used to output messages to the console. While Write-Host is suitable for displaying information directly to the user, it has limitations such as not being able to redirect output or capture it in a pipeline. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information, which are more versatile and provide better control over output.
To fix the issue, we can replace Write-Host with Write-Output, which will allow the message to be captured or redirected if needed.
Here's the code suggestion:
| Write-Host "❌ $label/$relativePath does not match expected" | |
| Write-Output "❌ $label/$relativePath does not match expected" |
This comment was generated by an experimental AI tool.
|
|
||
| $relativePath = $_.FullName.Replace($expectedDir, '').TrimStart('\') | ||
| $actualFile = Join-Path $actualDir $relativePath | ||
| Write-Host "`nChecking file: $relativePath" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used to output information to the console. While Write-Host does display messages directly to the host, it has limitations. Specifically, it may not work in all environments, cannot be captured or redirected, and prior to PowerShell 5.0, it could not be suppressed. The recommendation is to use Write-Output, Write-Verbose, or Write-Information instead, which are more versatile and suitable for scripting.
To address this specific line of code, we can replace Write-Host with Write-Output. Here's the single line change:
| Write-Host "`nChecking file: $relativePath" | |
| Write-Output "`nChecking file: $relativePath" |
This comment was generated by an experimental AI tool.
|
|
||
| if (-not (Test-Path $actualFile)) { | ||
| Write-Host "❌ $label/$($_.Name) does not exist in actual output" | ||
| Write-Host "❌ $label/$relativePath does not exist in actual output" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is being used to output messages to the console. While Write-Host can display information to the user, it is not the best practice for logging or outputting information in PowerShell scripts because it does not allow for the output to be captured, redirected, or suppressed. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information for better flexibility and compatibility.
To address this issue, we can replace Write-Host with Write-Information, which is a more suitable alternative for logging informational messages. Here is the single line change to fix the issue:
| Write-Host "❌ $label/$relativePath does not exist in actual output" | |
| Write-Information "❌ $label/$relativePath does not exist in actual output" |
This comment was generated by an experimental AI tool.
| Write-Host "❌ $label/$relativePath does not exist in actual output" | ||
| Write-Host "Expected: $($_.FullName)" | ||
| Write-Host "Actual should be: $actualFile" | ||
| Write-Host "Current directory structure:" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used for outputting messages. Write-Host directly writes to the console and is not suitable for scenarios where output needs to be captured, redirected, or suppressed. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information for better flexibility and compatibility.
To fix the issue, you can replace Write-Host with Write-Output in the line where the current directory structure is being printed. This change will allow the output to be captured or redirected if needed.
Here's the suggested code change:
| Write-Host "Current directory structure:" | |
| Write-Output "Current directory structure:" |
This comment was generated by an experimental AI tool.
| Write-Host "Current working directory: $(Get-Location)" | ||
| Write-Host "CLI Path: $CLI_PATH" | ||
| Write-Host "OS: $([System.Environment]::OSVersion.Platform)" | ||
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is being used to output information to the console. While Write-Host works for displaying messages directly to the host, it has limitations, such as not being able to redirect output or capture it in a pipeline. This can lead to problems in scenarios where you want to log information or use the output programmatically. Instead, it's recommended to use Write-Output, Write-Verbose, or Write-Information, which are more flexible and can be used in a variety of contexts.
To resolve this issue, you can replace Write-Host with Write-Output for the line that outputs the PowerShell version. This will allow the information to be captured or redirected if necessary.
Here’s the suggested code change:
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" | |
| Write-Output "PowerShell Version: $($PSVersionTable.PSVersion)" |
This comment was generated by an experimental AI tool.
|
|
||
| Write-Host "`n=== Starting Directory Comparison ===" | ||
| Write-Host "Comparing directories:" | ||
| Write-Host "Expected dir: $expectedDir" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is generally discouraged because it writes directly to the console and does not allow for output redirection or capturing. This can lead to problems in different PowerShell hosts or when running scripts in environments where console output is not available. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information for better compatibility and flexibility.
To fix the issue, you can replace Write-Host with Write-Output, which allows the output to be captured or redirected. Here’s the suggested change:
| Write-Host "Expected dir: $expectedDir" | |
| Write-Output "Expected dir: $expectedDir" |
This comment was generated by an experimental AI tool.
| $expectedDir = (Resolve-Path $expectedDir).Path | ||
| $actualDir = (Resolve-Path $actualDir).Path | ||
|
|
||
| Write-Host "Resolved paths:" |
There was a problem hiding this comment.
The issue identified by PSScriptAnalyzer is that Write-Host is being used for output. While Write-Host displays information directly to the console, it has limitations such as not being able to redirect output or work in all environments. Instead, it is recommended to use Write-Output, Write-Verbose, or Write-Information, which provide more flexibility and are better practices for script output.
To resolve this issue, you can replace the Write-Host command with Write-Output for the line that produces the "Resolved paths:" output. This change allows the output to be captured or redirected if needed.
Here's the suggested code change:
| Write-Host "Resolved paths:" | |
| Write-Output "Resolved paths:" |
This comment was generated by an experimental AI tool.
| Write-Host "=== Environment Information ===" | ||
| Write-Host "Script directory: $SCRIPT_DIR" | ||
| Write-Host "Current working directory: $(Get-Location)" | ||
| Write-Host "CLI Path: $CLI_PATH" |
There was a problem hiding this comment.
The issue identified by PSScriptAnalyzer is that Write-Host is not recommended for outputting information in PowerShell scripts because it writes directly to the host's console, making it difficult to capture or redirect the output. This can lead to issues in environments where the script might be run in different contexts (e.g., automated scripts, logging, etc.). Instead, it's better to use Write-Output, Write-Verbose, or Write-Information for more flexible output handling.
To fix the issue in the provided code, you can replace Write-Host with Write-Output. Here’s the suggested change:
| Write-Host "CLI Path: $CLI_PATH" | |
| Write-Output "CLI Path: $CLI_PATH" |
This comment was generated by an experimental AI tool.
| Write-Host "Actual dir (resolved): $actualDir" | ||
|
|
||
| # List directory contents before comparison | ||
| Write-Host "`nExpected directory contents:" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer linter is that Write-Host is not recommended for outputting information because it is not suitable for all PowerShell hosts and cannot be redirected or captured. Instead, it's better to use Write-Output, Write-Verbose, or Write-Information for better compatibility and flexibility in handling output.
To address this issue, you can replace Write-Host with Write-Output, which allows the output to be captured or redirected if needed.
Here's the code suggestion to fix the issue:
| Write-Host "`nExpected directory contents:" | |
| Write-Output "`nExpected directory contents:" |
This comment was generated by an experimental AI tool.
| Write-Host "`n=== Starting Directory Comparison ===" | ||
| Write-Host "Comparing directories:" | ||
| Write-Host "Expected dir: $expectedDir" | ||
| Write-Host "Actual dir: $actualDir" |
There was a problem hiding this comment.
The issue identified by the PSScriptAnalyzer is that Write-Host is not recommended for outputting information in PowerShell scripts because it writes directly to the host and cannot be captured, redirected, or suppressed. Instead, it's better to use Write-Output, Write-Verbose, or Write-Information, which are more flexible and compatible with various environments.
To fix the issue, you can replace Write-Host with Write-Output. Here's the single line change:
| Write-Host "Actual dir: $actualDir" | |
| Write-Output "Actual dir: $actualDir" |
This comment was generated by an experimental AI tool.
This pull request introduces significant changes to streamline runtime and tool management in the codebase by introducing a plugin-based architecture. The most important updates include the addition of a
PluginManagerfor handling runtime and tool configurations, refactoring runtime installation logic to use this new system, and simplifying runtime and tool version management. Below is a breakdown of the key changes:Plugin-Based Architecture for Runtimes and Tools:
PluginManagerinplugins/plugin_manager.goto manage runtime and tool plugins. This provides methods for retrieving runtime configurations, tool configurations, default versions, and runtime dependencies.processRuntimefunction inplugins/runtime-utils.goto use thePluginManagerfor retrieving runtime configurations and mapping architecture/OS values. This simplifies runtime processing and makes it more modular. [1] [2]Refactoring Runtime Installation Logic:
isRuntimeInstalledfunction withConfig.IsRuntimeInstalledto centralize runtime installation checks and improve testability. [1] [2] [3]config/runtimes-installer_test.goto reflect the new runtime installation logic. [1] [2]Simplification of Runtime and Tool Version Management:
PluginManagerto retrieve default versions for runtimes and tools (GetRuntimeVersions,GetToolVersions) and their runtime dependencies (GetToolRuntimeDependencies).configFileTemplatefunction incmd/init.goto dynamically fetch runtime and tool versions using thePluginManager. This eliminates hardcoded version mappings and ensures consistency. [1] [2]Configuration File Updates:
.codacy/codacy.yamlto reorganize the list of runtimes and tools, ensuring a consistent order..cursor/rules/cursor.mdcto apply rules to all files (globs: *.*) and disable thealwaysApplyflag.Code Cleanup and Minor Enhancements:
plugins/runtime-utils.go, such as the olddownloadConfigandisRuntimeInstalledlogic, to reduce redundancy. [1] [2]cmd/init.go("sort"and"codacy/cli-v2/plugins") to support sorting and plugin integration. [1] [2]- Modify cursor rule to disable alwaysApply